
<template>
    <div>
        <!-- logo -->
        <div class="logo">
            <div class="logo-left">
                <img src="../assets/1.png" alt="">
            </div>
            <div class="logo-right">下载APP</div>
        </div>
        <!-- tab栏 -->
        <div>
            <van-tabs V-model="active">
                <van-tab :to="item.to" :title="item.name" v-for="(item, index) in List" :key="index" />
                <router-view />
            </van-tabs>
        </div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            // tab栏默认下标
            active: 0,
            // tab栏的数据
            List: [
                {
                    name: "推荐",
                    to: { name: 'Home' }
                },
                {
                    name: "热歌",
                    to: { name: 'Hot' }
                },
                {
                    name: "搜索",
                    to: { name: 'Search' }
                }
            ]
        };
    },
    created() {
        console.log(this.$route.name);
        for (let i = 0; i < this.List.length; i++) {
            if (this.List[i].to.name == this.$route.name) {
                this.active = i;
                return
            }
        }
    }
};
</script>
<style lang="less" scoped>
.logo {
    display: flex;
    height: 100px;
    background-color: #be2322;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;


    .logo-left {
        width: 50px;

        img {
            width: 100px;
        }
    }

    .logo-right {
        width: 100px;
        height: 40px;
        background-color: #fff;
        color: #D43C33;
        text-align: center;
        line-height: 40px;
        border-radius: 30px;
    }
}
</style>
    
    